var mongoose = require("mongoose");

//积分兑换表(exchange)

var exchangeSchema = new mongoose.Schema({
  userid: {
    type: mongoose.SchemaTypes.ObjectId,
    ref: "user_login",
    required: true
  }, //用户id
  commodityid: {
    type: mongoose.SchemaTypes.ObjectId,
    ref: "commodity",
    required: true
  }, //商品id
  exchangeTpye: { type: String }, //兑换方式  //邮寄  自提
  order_time: { type: Date, default: new Date() }, //订单时间
  receiving_address: {
    contacts: { type: String },
    phone: { type: String },
    address: { type: String }
  }, //收货地址
  send_num: { type: String }, //快递单号
  exchange_num: { type: String }, //兑换码
  exchange_state: { type: Boolean, default: false } //兑换状态
});

module.exports = mongoose.model("exchange", exchangeSchema);
